import { addStock, delStock, searchStock } from '@/api/stock'
const stock = {
  state: {},

  mutations: {},

  actions: {
    // 新增
    AddStock ({ commit }, stockInfo) {
      return new Promise((resolve, reject) => {
        addStock(stockInfo)
          .then(response => {
            resolve(response)
          })
          .catch(error => {
            reject(error)
          })
      })
    },
    // 删除
    DelStock ({ commit }, id) {
      console.log(id)
      return new Promise((resolve, reject) => {
        delStock(id)
          .then(response => {
            resolve(response)
          })
          .catch(error => {
            reject(error)
          })
      })
    },
    // 搜索
    SearchStock ({ commit }, id) {
      return new Promise((resolve, reject) => {
        searchStock(id)
          .then(response => {
            resolve(response)
          })
          .catch(error => {
            reject(error)
          })
      })
    }
  }
}

export default stock
